/***************************************************************************
 *   KShootout - online shootout card game.                                *
 *   Copyright (C) 2008, 2009  MacJariel                                   *
 *                                                                         *
 *   KShootout is free software: you can redistribute it and/or modify     *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation, either version 3 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   KShootout is distributed in the hope that it will be useful,          *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with KShootout.  If not, see <http://www.gnu.org/licenses/>.    *
 ***************************************************************************/

#include "stringconverter.h"
#include <QStringList>
#include <QDateTime>
#include <QList>
#include <QLocale>

QString toString(const QDateTime& r)
{
    return r.toString(Qt::ISODate);
}

void fromString(const QString& s, QDateTime& r)
{
    r = QDateTime::fromString(s, Qt::ISODate);
}

QString toString(const QList<QLocale>& r)
{
    QStringList res;
    foreach(const QLocale& l, r) {
        res.append(l.name());
    }
    return res.join(",");
}

void fromString(const QString& s, QList<QLocale>& r)
{
    r.clear();
    foreach(const QString& l, s.split(",")) {
        r.append(QLocale(l));
    }
}
